
function jsSelectItemByValue(objSelect,objItemText) {  
        for(var i=0;i<objSelect.options.length;i++) {  
            if(objSelect.options[i].value == objItemText) {  
                objSelect.options[i].selected = true;  
                break;  
            }  
        }  
    }  

function addItems(objSelect,url,hasSelect,language) {
    $.ajax({
    	async : false,
        url: url,    //后台webservice里的方法名称
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
    		var optionstring = "";
            for (var i in data) {
                var jsonObj =data[i];
                optionstring += "<option value=\"" + jsonObj.key + "\" >" + jsonObj.value + "</option>";
            }
            if(hasSelect){
            	if(language == 'en') {
            		objSelect.html("<option value='' class='text-left'>--Please Select--</option> "+optionstring);
            	}else{
            		objSelect.html("<option value='' class='text-left'>--请选择--</option> "+optionstring);
            	}
            	
            }else{
            	objSelect.html("<option value='' class='text-left'></option> "+optionstring);
            }
        },
        error: function (msg) {
            alert(objSelect.id + "select error");
        }
    });          
}
function addItemsWithPlaceholder(objSelect,url,hasSelect,placeholder) {
    $.ajax({
    	async : false,
        url: url,    //后台webservice里的方法名称
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
    		var optionstring = "";
            for (var i in data) {
                var jsonObj =data[i];
                optionstring += "<option value=\"" + jsonObj.key + "\" >" + jsonObj.value + "</option>";
            }
            if(hasSelect){
            	objSelect.html("<option value='' class='text-left'>--"+placeholder+"--</option> "+optionstring);
            }else{
            	objSelect.html("<option value='' class='text-left'></option> "+optionstring);
            }
        },
        error: function (msg) {
            alert(objSelect.id + "select error");
        }
    });          
}
function addItemsWithPlaceholder(objSelect,url,hasSelect,placeholder) {
    $.ajax({
    	async : false,
        url: url,    //后台webservice里的方法名称
        type: "post",
        dataType: "json",
        contentType: "application/json",
        traditional: true,
        success: function (data) {
    		var optionstring = "";
            for (var i in data) {
                var jsonObj =data[i];
                optionstring += "<option value=\"" + jsonObj.key + "\" >" + jsonObj.value + "</option>";
            }
            if(hasSelect){
            	objSelect.html("<option value='' class='text-left'>--"+placeholder+"--</option> "+optionstring);
            }else{
            	objSelect.html("<option value='' class='text-left'></option> "+optionstring);
            }
        },
        error: function (msg) {
            alert(objSelect.id + "select error");
        }
    });      
}

